package com.share.hope.controller;

import com.share.hope.entity.Vocabulary;
import com.share.hope.entity.page.PageQueryVo;
import com.share.hope.entity.result.PageR;
import com.share.hope.entity.result.R;
import com.share.hope.service.VocabularyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/share/hope/vocabulary")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "單詞本信息管理接口")
@CrossOrigin
public class VocabularyController {

    private final VocabularyService vocabularyService;

    @PostMapping("/create")
    public R<String> createVocabulary(@RequestBody Vocabulary vocabulary) {
        return vocabularyService.createVocabulary(vocabulary);
    }

    @PostMapping("/update")
    public R<String> updateVocabulary(@RequestBody Vocabulary vocabulary) {
        return vocabularyService.updateVocabulary(vocabulary);
    }

    @GetMapping("/delete")
    public R<String> deleteVocabulary(@RequestParam Long id) {
        return vocabularyService.deleteVocabulary(id);
    }

    @PostMapping("/page")
    @Operation(summary = "分页查询")
    public R<PageR<Vocabulary>> pageVocabulary(@RequestBody PageQueryVo<Vocabulary> queryVo) {
        return vocabularyService.pageVocabulary(queryVo);
    }
}
